<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.javaee.ejb.entity.Employee"  %>
<%@ page import="com.javaee.ejb.entity.Message"  %>
<%@ page import="java.util.List"  %>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Conversation</title>
<link rel="stylesheet" type="text/css" media="screen" href="/ProjetWebEAR/css/main.css" />
<script type="text/javascript" src="/ProjetWebEAR/js/jquery.js" ></script>
<script type="text/javascript" src="/ProjetWebEAR/js/chat.js" ></script>


</head>
<body>
	<div id="wrapper">
		<div class="header">
			
			Bonjour <%= ((Employee)request.getSession().getAttribute("currentEmp")).getFirstname() %>, 
			vous parlez à <%= ((Employee)request.getSession().getAttribute("calledEmp")).getFirstname() %>
			
		</div>
		<div id="chat">
		<div id="messages">
			<ul>
				<% List<Message> msgs = (List<Message>)request.getAttribute("messages");
				for (Message m:msgs)
				{
				%>
				<li><span class="author"><%= ((Employee)request.getSession().getAttribute("currentEmp")).getIdemployee() == m.getAuthorId() ? ((Employee)request.getSession().getAttribute("currentEmp")).getFirstname() : ((Employee)request.getSession().getAttribute("calledEmp")).getFirstname() %></span> # <%= m.getContent() %></li>
			<%
				}
			%>
			</ul>
		</div>
		<div id="message">
			<form action="ChatServlet" method="POST" id="chatform">
				<input type="text" id="text" name="content">
				<input type="hidden" value="<%= request.getParameter("caller") %>" id="caller"/>
				<input type="hidden" value="<%= request.getParameter("called") %>" id="called"/>
				<input type="submit" id="send" value="Envoyer"/>
				
			</form>
		</div>
		</div>
	</div>
</body>
</html>